package com.guomao.anli;

import java.util.Comparator;
import java.util.TreeSet;

public class TestStudent {


    public static void main(String[] args) {


   /*     TreeSet<Student> ss = new TreeSet<>(
                new Comparator<Student>() {
                    public int compare(Student o1, Student o2) {
                        return o2.getScore() - o1.getScore();
                    }
                });*/


    /*    TreeSet<Student> ss = new TreeSet<>(
                new Comparator<>() {
                    public int compare(Student o1, Student o2) {
                        return o2.getScore() - o1.getScore();
                    }
                });*/


//        TreeSet<Student> ss = new TreeSet<>((o1, o2) -> o2.getScore() - o1.getScore());


/*        TreeSet<Student> ss = new TreeSet<>((Student o1, Student o2) -> {
            return o2.getScore() - o1.getScore();
        });*/

       /* TreeSet<Student> ss = new TreeSet<>(( o1,  o2) -> {
            return o2.getScore() - o1.getScore();
        });*/

        //可推导 可省略
        /*        TreeSet<Student> ss = new TreeSet<>((o1, o2) -> o2.getScore() - o1.getScore());*/

/*
        TreeSet<Student> ss = new TreeSet<>((o1, o2) -> {
            int result = o2.getScore() - o1.getScore();
            result = result != 0 ? result : o1.getName().compareTo(o2.getName());
            return result;
        });*/


        TreeSet<Student> ss = new TreeSet<>((o1, o2) -> o1.getScore() - o2.getScore());

        Student root = new Student("root", 30, 99);
        Student bob = new Student("bob", 27, 90);
        Student admin = new Student("admin", 25, 93);


        ss.add(root);
        ss.add(bob);
        ss.add(admin);


        System.out.println(ss);
    }
}
